Xbasic
FILE.FILENAME_PARSE Function
Syntax
String as C = FILE.Filename_Parse(Filename as C,Component as C)
Arguments
- FilenameCharacter
The name of the file.
- ComponentCharacter
Component can contain one or more of the following flags:
- "d"
drive
- "p"
path
- "n"
name
- "e"
extension
- "u"
UNC machine name
- "s"
subdirectory
Returns
- StringCharacter
The requested portion of the filename.
Description
Returns the component(s) of the filename in the order specified (D=drive, P=Path, N=Name, E=Extension, U=UNC Machine Name, S=Subdirectory).
Discussion
The FILE.FILENAME_PARSE() method parses filename, and returns the specified component (drive, path, name or extension) of Filename.
Example
Using the sample Invoice application that ships with Alpha Anywhere, type this in the Interactive window.
t = table.open("customer") filename = t.filename_get() ? filename = "K:\PROGRAM FILES\A5V4\TEMPLATES\DATABASES\INVOICE\CUSTOMER.DBF" ? FILE.filename_parse(filename,"d") = "K:" ? FILE.filename_parse(filename,"p") = "\PROGRAM FILES\A5V4\TEMPLATES\DATABASES\INVOICE\" ? FILE.filename_parse(filename,"n") = "CUSTOMER" ? FILE.filename_parse(filename,"e") = ".DBF" ? FILE.filename_parse(filename,"ne") = "CUSTOMER.DBF" ? FILE.filename_parse(filename,"dne") = "K:CUSTOMER.DBF" ? FILE.filename_parse(a5.get_name(),"ne") = "example.adb"
See Also